Set classes info in GtkWidgetPath.
authorCarlos Garnacho <carlosg@gnome.org>
Fri, 6 Aug 2010 10:06:29 +0000 (12:06 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Sat, 4 Dec 2010 14:37:36 +0000 (15:37 +0100)
gtk/gtkstylecontext.c
gtk/gtkwidget.c

index 647d09078f117d29b41260fb0417715ff6a65e6c..f944014ab289d009b64f859cab9337ec7676d5d8 100644 (file)
@@ -669,9 +669,10 @@ gtk_style_context_restore (GtkStyleContext *context)
     {
       guint i;
 
+      info = priv->info_stack->data;
+
       /* Update widget path regions */
       gtk_widget_path_iter_clear_regions (priv->widget_path, 0);
-      info = priv->info_stack->data;
 
       for (i = 0; i < info->regions->len; i++)
         {
@@ -682,6 +683,18 @@ gtk_style_context_restore (GtkStyleContext *context)
                                            g_quark_to_string (region->class_quark),
                                            region->flags);
         }
+
+      /* Update widget path classes */
+      gtk_widget_path_iter_clear_classes (priv->widget_path, 0);
+
+      for (i = 0; i < info->style_classes->len; i++)
+        {
+          GQuark quark;
+
+          quark = g_array_index (info->style_classes, GQuark, i);
+          gtk_widget_path_iter_add_class (priv->widget_path, 0,
+                                          g_quark_to_string (quark));
+        }
     }
 }
 
@@ -788,7 +801,15 @@ gtk_style_context_set_class (GtkStyleContext *context,
   info = priv->info_stack->data;
 
   if (!style_class_find (info->style_classes, class_quark, &position))
-    g_array_insert_val (info->style_classes, position, class_quark);
+    {
+      g_array_insert_val (info->style_classes, position, class_quark);
+
+      if (priv->widget_path)
+        {
+          gtk_widget_path_iter_add_class (priv->widget_path, 0, class_name);
+          rebuild_properties (context);
+        }
+    }
 }
 
 void
@@ -814,7 +835,15 @@ gtk_style_context_unset_class (GtkStyleContext *context,
   info = priv->info_stack->data;
 
   if (style_class_find (info->style_classes, class_quark, &position))
-    g_array_remove_index (info->style_classes, position);
+    {
+      g_array_remove_index (info->style_classes, position);
+
+      if (priv->widget_path)
+        {
+          gtk_widget_path_iter_remove_class (priv->widget_path, 0, class_name);
+          rebuild_properties (context);
+        }
+    }
 }
 
 gboolean
index e9c493751770e3f77e600ede451750e9b10065d0..6321348ea2ca9c5acb8c3e72734b891e0977a39f 100644 (file)
@@ -13216,7 +13216,6 @@ gtk_widget_get_path (GtkWidget *widget)
   GtkStyleContext *context;
   GtkWidgetPath *path;
   GtkWidget *parent;
-  GList *regions, *reg;
 
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
 
@@ -13224,7 +13223,6 @@ gtk_widget_get_path (GtkWidget *widget)
 
   path = gtk_widget_path_new ();
   gtk_widget_path_prepend_type (path, G_OBJECT_TYPE (widget));
-  regions = reg = NULL;
 
   if (widget->priv->name)
     gtk_widget_path_iter_set_name (path, 0, widget->priv->name);
@@ -13233,21 +13231,39 @@ gtk_widget_get_path (GtkWidget *widget)
                                 quark_style_context);
 
   if (context)
-    regions = reg = gtk_style_context_list_regions (context);
-
-  while (reg)
     {
-      GtkRegionFlags flags;
-      const gchar *region_name;
+      GList *list, *l;
 
-      region_name = reg->data;
-      reg = reg->next;
+      list = l = gtk_style_context_list_regions (context);
 
-      gtk_style_context_has_region (context, region_name, &flags);
-      gtk_widget_path_iter_add_region (path, 0, region_name, flags);
-    }
+      while (l)
+        {
+          GtkRegionFlags flags;
+          const gchar *region_name;
+
+          region_name = l->data;
+          l = l->next;
+
+          gtk_style_context_has_region (context, region_name, &flags);
+          gtk_widget_path_iter_add_region (path, 0, region_name, flags);
+        }
+
+      g_list_free (list);
 
-  g_list_free (regions);
+      list = l = gtk_style_context_list_classes (context);
+
+      while (l)
+        {
+          const gchar *class_name;
+
+          class_name = l->data;
+          l = l->next;
+
+          gtk_widget_path_iter_add_class (path, 0, class_name);
+        }
+
+      g_list_free (list);
+    }
 
   while (parent)
     {